import matplotlib.pyplot as plt
import numpy as np

x = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8])
y1 = np.array([0, 25, 36, 55, 37, 46, 53, 59, 64])  # p90 latency
y2 = np.array([0, 54.44, 71.84, 68.42, 140.22, 155.45, 157.07, 159.36, 163.67])  # throughput
y3 = np.array([0, 74.8, 95.46, 105.18, 330.06, 365.07, 375.10, 377.05, 377.49])  # cpu utilization

plt.xlabel('Threads(number)')
plt.ylabel('')

plt.axis([0, 10, 0, 400])
plt.plot(x, y1, label='p90 Latency(ms)')
plt.plot(x, y2, label='Throughput(doc/s)')
plt.plot(x, y3, label='CPU utilization(%)')

# 保存图像到文件
plt.savefig('plot.png', bbox_inches='tight')
plt.legend(loc='best')
# 显示图像
plt.show()

# 打印已保存的图像文件路径
print("图像已保存到:plot.png")
